﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;

namespace VS4CRM.Lib.Services
{

    public class CrmServiceProxy : ICrmService
    {
        public CrmService Service { get; private set; }

        #region Construction
        public CrmServiceProxy(CrmService service)
        {
            this.Service = service;
        }
        private CrmServiceProxy() { }
        #endregion

        #region ICrmService Members
        Guid ICrmService.Create(BusinessEntity entity)
        {
            return this.Service.Create(entity);
        }

        void ICrmService.Delete(string entityName, Guid id)
        {
            this.Service.Delete(entityName, id);
        }

        object ICrmService.Execute(object request)
        {
            return this.Service.Execute((Request)request);
        }

        string ICrmService.Fetch(string fetchXml)
        {
            return this.Service.Fetch(fetchXml);
        }

        BusinessEntity ICrmService.Retrieve(string entityName, Guid id, Microsoft.Crm.Sdk.Query.ColumnSetBase columnSet)
        {
            return this.Service.Retrieve(entityName, id, columnSet);
        }

        BusinessEntityCollection ICrmService.RetrieveMultiple(Microsoft.Crm.Sdk.Query.QueryBase query)
        {
            return this.Service.RetrieveMultiple(query);
        }

        void ICrmService.Update(BusinessEntity entity)
        {
            this.Service.Update(entity);
        }

        #endregion

        #region IDisposable Members
        void IDisposable.Dispose()
        {
            this.Service.Dispose();
        }
        #endregion
    }
}
